import 'package:wch/generated/json/base/json_convert_content.dart';
import 'package:wch/model/patient_detail.dart';
import 'package:flutter/cupertino.dart';


PatientDetailEntity $PatientDetailEntityFromJson(Map<String, dynamic> json) {
  final PatientDetailEntity patientDetailEntity = PatientDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    patientDetailEntity.id = id;
  }
  final int? hospitalId = jsonConvert.convert<int>(json['hospitalId']);
  if (hospitalId != null) {
    patientDetailEntity.hospitalId = hospitalId;
  }
  final int? doctorId = jsonConvert.convert<int>(json['doctorId']);
  if (doctorId != null) {
    patientDetailEntity.doctorId = doctorId;
  }
  final int? num = jsonConvert.convert<int>(json['num']);
  if (num != null) {
    patientDetailEntity.num = num;
  }
  final String? templateName = jsonConvert.convert<String>(
      json['templateName']);
  if (templateName != null) {
    patientDetailEntity.templateName = templateName;
  }
  final String? adminUser = jsonConvert.convert<String>(json['adminUser']);
  if (adminUser != null) {
    patientDetailEntity.adminUser = adminUser;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    patientDetailEntity.createTime = createTime;
  }
  final String? updateTime = jsonConvert.convert<String>(json['updateTime']);
  if (updateTime != null) {
    patientDetailEntity.updateTime = updateTime;
  }
  final List<PatientDetailList>? list = (json['list'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<PatientDetailList>(e) as PatientDetailList)
      .toList();
  if (list != null) {
    patientDetailEntity.list = list;
  }
  return patientDetailEntity;
}

Map<String, dynamic> $PatientDetailEntityToJson(PatientDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['hospitalId'] = entity.hospitalId;
  data['doctorId'] = entity.doctorId;
  data['num'] = entity.num;
  data['templateName'] = entity.templateName;
  data['adminUser'] = entity.adminUser;
  data['createTime'] = entity.createTime;
  data['updateTime'] = entity.updateTime;
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  return data;
}

extension PatientDetailEntityExtension on PatientDetailEntity {
  PatientDetailEntity copyWith({
    int? id,
    int? hospitalId,
    int? doctorId,
    int? num,
    String? templateName,
    String? adminUser,
    String? createTime,
    String? updateTime,
    List<PatientDetailList>? list,
  }) {
    return PatientDetailEntity()
      ..id = id ?? this.id
      ..hospitalId = hospitalId ?? this.hospitalId
      ..doctorId = doctorId ?? this.doctorId
      ..num = num ?? this.num
      ..templateName = templateName ?? this.templateName
      ..adminUser = adminUser ?? this.adminUser
      ..createTime = createTime ?? this.createTime
      ..updateTime = updateTime ?? this.updateTime
      ..list = list ?? this.list;
  }
}

PatientDetailList $PatientDetailListFromJson(Map<String, dynamic> json) {
  final PatientDetailList patientDetailList = PatientDetailList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    patientDetailList.id = id;
  }
  final int? templateId = jsonConvert.convert<int>(json['templateId']);
  if (templateId != null) {
    patientDetailList.templateId = templateId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    patientDetailList.name = name;
  }
  final String? text = jsonConvert.convert<String>(json['text']);
  if (text != null) {
    patientDetailList.text = text;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    patientDetailList.type = type;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    patientDetailList.status = status;
  }
  final String? label = jsonConvert.convert<String>(json['label']);
  if (label != null) {
    patientDetailList.label = label;
  }
  final TextEditingController? controller = jsonConvert.convert<
      TextEditingController>(json['controller']);
  if (controller != null) {
    patientDetailList.controller = controller;
  }
  final int? minLength = jsonConvert.convert<int>(json['minLength']);
  if (minLength != null) {
    patientDetailList.minLength = minLength;
  }
  return patientDetailList;
}

Map<String, dynamic> $PatientDetailListToJson(PatientDetailList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['templateId'] = entity.templateId;
  data['name'] = entity.name;
  data['text'] = entity.text;
  data['type'] = entity.type;
  data['status'] = entity.status;
  data['label'] = entity.label;
  data['minLength'] = entity.minLength;
  return data;
}

extension PatientDetailListExtension on PatientDetailList {
  PatientDetailList copyWith({
    int? id,
    int? templateId,
    String? name,
    String? text,
    int? type,
    String? status,
    String? label,
    TextEditingController? controller,
    int? minLength,
  }) {
    return PatientDetailList()
      ..id = id ?? this.id
      ..templateId = templateId ?? this.templateId
      ..name = name ?? this.name
      ..text = text ?? this.text
      ..type = type ?? this.type
      ..status = status ?? this.status
      ..label = label ?? this.label
      ..controller = controller ?? this.controller
      ..minLength = minLength ?? this.minLength;
  }
}